package com.gitee.ly.model;

import lombok.Data;

@Data
public class JsonResult<T> {
    private int code;
    private String msg;
    private T data;

    //分页用
    private int total = 0;
    private int size = 0;

    public static <T> JsonResult<T> result(T data, int code, String msg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(code);
        jsonResult.setMsg(msg);
        jsonResult.setData(data);
        return jsonResult;
    }

    public static <T> JsonResult<T> result(T data, int total, int size, int code, String msg) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(code);
        jsonResult.setMsg(msg);
        jsonResult.setData(data);
        jsonResult.setTotal(total);
        jsonResult.setSize(size);
        return jsonResult;
    }
}
